# Python 2.6.4
# Project Euler, Problem 105
# Copyright 2010 Talha Zaman

def subsets(s, l):
    if l==1: return [[d] for d in s]
    elif l==0: return [[]]
    elif l<0: return []
    subs = []
    for i in range(len(s)):
        for j in subsets(s[i+1:], l-1):
            subs.append([s[i]] + j)
    return subs

def check(s):
    lastsum = 0
    for i in range(1, len(s)):
        sums = set()
        for sub in subsets(s, i):
            subsum = sum(sub)
            if subsum in sums or subsum <= lastsum: return 0
            sums.add(subsum)
        lastsum = max(sums)
    return sum(s)

sets = [[int(x) for x in s.strip().split(",")] for s in open("sets.txt").readlines()]
print sum(check(s) for s in sets)
